<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title></title>
  <style>
    .content {
      width: 600px;
      height: 200px;
      background-color: blue;
    }

    .content:nth-child(2n) {
      background-color: purple;
    }

    .target {
      width: 600px;
      height: 100px;
      background-color: pink;
      background-color: green;
      position: sticky;
      top: 100px;
    }
  </style>
</head>

<body>
  <div class="content"></div>
  <div class="content"></div>
  <div class="target">
    top必须写。当达到top条件时，由相对定位变为固定定位<br>
    .content:nth-child(2n)：表示第偶数个儿子并且是content类，而不是第偶数个content类
  </div>
  <div class="content"></div>
  <div class="content"></div>
  <div class="content"></div>
  <div class="content"></div>
  <div class="content"></div>
  <div class="content"></div>
  <div class="content"></div>
  <div class="content"></div>
</body>

</html>
